package monitor;

import gui.Dashboard;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class Listener implements ServletContextListener {

	Dashboard frame;
	Monitor monitor;
	
	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		frame.dispose();
	}

	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		try {
			frame = new Dashboard();
			monitor = new Monitor();
			monitor.addObserver(frame);
			frame.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
	
	public void showGUI() {
		frame.setVisible(true);
	}

}
